<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <table border="1">
        <tr>
            <td>照片：</td><td><img :src="p.imgUrl" height="200px" alt=""></td>
        </tr>
        <tr><td>名字：</td><td>{{p.name}}</td></tr>
        <tr><td>年龄：</td><td>{{p.age}}</td></tr>
        <tr><td>好友：</td>
            <td><ul>
                <li v-for="name in p.friends">{{name}}</li>
            </ul></td>
        </tr>
    </table>
    <input type="button" value="数据加载" @click="f()" />
</div>
</body>
<script src="js/vue.min.js"></script>
<script>
    let v = new Vue({
        el:"body>div",
        data:{
            p:{

            }
        },
        methods:{
            f(){
                //模拟数据是从服务器请求回来的
                v.p = {name:"传奇哥",
                    age:18,
                    imgUrl:"../a.jpg",
                    friends:["貂蝉","大乔","小乔","甄姬"]}
                //无效原因：VUE的最初监听，只有自定义对象P，没有里面的属性，若想添加属性还被监听
                //，第一次添加，必须让被监听的P来添加，而不是直接，添加一个属性
               /* v.p.name = "传奇哥222";
                v.p.age = 18;
                v.p.imgUrl = "../b.jpg";
                v.p.friends = ["西施","貂蝉","蔡文姬"];*/
            }
        }
    });
    console.log(v.p);
</script>
</html>